curr=$(cd "$(dirname "$0")";pwd)
dm_home=$(cd "$curr/../dm8";pwd)
mkdir -p $curr/../../dmdata_tpcc
dm_data=$(cd "$curr/../../dmdata_tpcc";pwd)
echo "dm_home: "$dm_home/bin " dm_data: "$dm_data
redo_size="2048"
kill -9 $(ps -ef|grep ${dm_home}/bin |gawk '$0 !~/grep/ {print $2}' |tr -s '\n' ' ')
sleep 10
chmod +x $curr/DmService $curr/alterini.py
rm -rf ${dm_data}
export LD_LIBRARY_PATH=$dm_home/bin
sed -i '/^DM_HOME/c DM_HOME="'${dm_home}'"' ${curr}/DmService
sed -i '/^INI_PATH/c INI_PATH='${dm_data}'/DAMENG/dm.ini' ${curr}/DmService
cd $dm_home/bin
./dminit path=${dm_data} page_size=32 extent_size=32 SYSDBA_PWD=hust4400_HZQ SYSAUDITOR_PWD=hust4400_HZQ port_num=25236 LOG_SIZE=2048
$curr/DmService start
sleep 60
cp ${curr}/DmService ${dm_data}
./disql SYSDBA/hust4400_HZQ@localhost:25236 << EOF
SP_SET_PARA_VALUE(2,'WORKER_THREADS',64);
SP_SET_PARA_VALUE(2,'IO_THR_GROUPS',16);
SP_SET_PARA_VALUE(2,'GEN_SQL_MEM_RECLAIM',0);
SP_SET_PARA_VALUE(2,'MAX_OS_MEMORY',       100);
SP_SET_PARA_VALUE(2,'MEMORY_POOL',         2000);
SP_SET_PARA_VALUE(2,'MEMORY_N_POOLS',      59);
SP_SET_PARA_VALUE(2,'MEMORY_TARGET',       83000);
SP_SET_PARA_VALUE(2,'BUFFER',              331000);
SP_SET_PARA_VALUE(2,'BUFFER_POOLS',        101);
SP_SET_PARA_VALUE(2,'RECYCLE',            33000);
SP_SET_PARA_VALUE(2,'RECYCLE_POOLS',       97);
SP_SET_PARA_VALUE(2,'FAST_POOL_PAGES',     99999);
SP_SET_PARA_VALUE(2,'FAST_ROLL_PAGES',     9999);
SP_SET_PARA_VALUE(2,'ENABLE_FREQROOTS',1);
SP_SET_PARA_VALUE(2,'MULTI_PAGE_GET_NUM',1);
SP_SET_PARA_VALUE(2,'PRELOAD_SCAN_NUM',0);
SP_SET_PARA_VALUE(2,'PRELOAD_EXTENT_NUM',0);
SP_SET_PARA_VALUE(2,'TASK_THREADS',8);
SP_SET_PARA_VALUE(2,'MEMORY_MAGIC_CHECK',       1);
SP_SET_PARA_VALUE(1,'HJ_BUF_GLOBAL_SIZE',  84000);
SP_SET_PARA_VALUE(1,'HJ_BUF_SIZE',        512);
SP_SET_PARA_VALUE(1,'HAGR_BUF_GLOBAL_SIZE',52000);
SP_SET_PARA_VALUE(1,'HAGR_BUF_SIZE',     512);
SP_SET_PARA_VALUE(2,'SORT_FLAG',0);
SP_SET_PARA_VALUE(2,'SORT_BLK_SIZE',2);
SP_SET_PARA_VALUE(2,'SORT_BUF_SIZE',       2);
SP_SET_PARA_VALUE(2,'SORT_BUF_GLOBAL_SIZE',       84000);
SP_SET_PARA_VALUE(2,'RLOG_POOL_SIZE',      2048);
SP_SET_PARA_VALUE(2,'CACHE_POOL_SIZE',     2048);
SP_SET_PARA_VALUE(2,'DICT_BUF_SIZE',       1024);
SP_SET_PARA_VALUE(2,'VM_POOL_TARGET',      8192);
SP_SET_PARA_VALUE(2,'SESS_POOL_TARGET',    8192);
SP_SET_PARA_VALUE(2,'USE_PLN_POOL',        1);
SP_SET_PARA_VALUE(2,'ENABLE_MONITOR',      1);
SP_SET_PARA_VALUE(2,'SVR_LOG',             0);
SP_SET_PARA_VALUE(2,'TEMP_SIZE',           1024);
SP_SET_PARA_VALUE(2,'TEMP_SPACE_LIMIT',    102400);
SP_SET_PARA_VALUE(2,'MAX_SESSIONS',        10300);
SP_SET_PARA_VALUE(2,'MAX_SESSION_STATEMENT', 20000);
SP_SET_PARA_VALUE(2,'PK_WITH_CLUSTER',		1);
SP_SET_PARA_VALUE(2,'ENABLE_ENCRYPT',0);
SP_SET_PARA_VALUE(2,'OLAP_FLAG',2);
SP_SET_PARA_VALUE(2,'VIEW_PULLUP_FLAG',1);
SP_SET_PARA_VALUE(2,'OPTIMIZER_MODE',1);
SP_SET_PARA_VALUE(2,'ADAPTIVE_NPLN_FLAG',0);
SP_SET_PARA_VALUE(2,'MONITOR_INDEX_FLAG',2);
SP_SET_PARA_VALUE(2,'ENABLE_CREATE_BM_INDEX_FLAG',0);
SP_SET_PARA_VALUE(2,'PARALLEL_PURGE_FLAG',1);
SP_SET_PARA_VALUE(2,'PARALLEL_POLICY',2);
SP_SET_PARA_DOUBLE_VALUE(2,'UNDO_RETENTION',90);
SP_SET_PARA_VALUE(2,'UNDO_EXTENT_NUM',16);
SP_SET_PARA_VALUE(2,'ENABLE_INJECT_HINT',1);
SP_SET_PARA_VALUE(2,'BTR_SPLIT_MODE',1);
SP_SET_PARA_VALUE(2,'FAST_LOGIN',1);
SP_SET_PARA_VALUE(2,'ENABLE_MONITOR_BP',0);
exit
EOF

#modfiy the manual parameters
python ${curr}/alterini.py ${dm_data}/DAMENG/dm.ini ${curr}/dm.ini
sleep 1
$curr/DmService restart
sleep 1
$curr/DmService restart
sleep 30
